package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.ts.domain.req.examinationRecord.ListExaminationRecordRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.ExaminationRecordBO;
import com.xy.biz.ts.domain.po.ExaminationRecordPO;
import com.xy.biz.ts.domain.query.ExaminationRecordQuery;
import com.xy.biz.ts.domain.resp.GetExaminationRecordResponse;
import com.xy.biz.ts.domain.req.SaveExaminationRecordRequest;

/**
 *
 *
 * @author wcs
 * @date 2021-3-10
 */
public class ExaminationRecordConverter {

	public static ExaminationRecordPO toPO(ExaminationRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExaminationRecordPO(), true);
	}

	public static List<ExaminationRecordPO> toPO(Collection<ExaminationRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationRecordPO(), true);
	}

	public static ExaminationRecordBO fromPO(ExaminationRecordPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExaminationRecordBO());
	}

	public static List<ExaminationRecordBO> fromPO(Collection<ExaminationRecordPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationRecordBO());
	}

	public static ExaminationRecordBO toBO(SaveExaminationRecordRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExaminationRecordBO(), true);
	}

	public static List<ExaminationRecordBO> toBO(Collection<SaveExaminationRecordRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationRecordBO(), true);
	}

	public static GetExaminationRecordResponse toResponse(ExaminationRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetExaminationRecordResponse());
	}

	public static List<GetExaminationRecordResponse> toResponse(Collection<ExaminationRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetExaminationRecordResponse());
	}

	public static ExaminationRecordQuery toQuery(ListExaminationRecordRequest source) {
		if(null == source) {
			return null;
		}
		ExaminationRecordQuery target = new ExaminationRecordQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
